﻿using System;
using System.Collections;
using System.Collections.Generic;
using TUIO;

namespace Recognizer.NIH.Models
{
    class CursorList
    {
        private Dictionary<long, ArrayList> cursorList;
        public Dictionary<long, ArrayList> Cursors { get { return cursorList; } }
        public CursorList()
        {
            cursorList = new Dictionary<long, ArrayList>();
        }
        public int Size()
        {
            return cursorList.Count;
        }
        public void addCursor(TuioCursor c)
        {
            ArrayList tmp = new ArrayList();
            tmp.Add(new PointR(c.getX(), c.getY(), Environment.TickCount, c.getCursorID()));
            cursorList.Add(c.getSessionID(), tmp);
        }

        public void updateCursor(TuioCursor c)
        {
            ArrayList tmp;
            if (cursorList.ContainsKey(c.getSessionID()))
            {
                tmp = cursorList[c.getSessionID()];
                tmp.Add(new PointR(c.getX(), c.getY(), Environment.TickCount, c.getCursorID()));
            }
            else
            {
                tmp = new ArrayList();
                tmp.Add(new PointR(c.getX(), c.getY(), Environment.TickCount, c.getCursorID()));
                cursorList.Add(c.getSessionID(), tmp);
            }
        }
        public void removeCursor(TuioCursor c)
        {
            cursorList.Remove(c.getSessionID());
        }
        public ArrayList getPath(TuioCursor c)
        {
            ArrayList tmp;
            if (cursorList.ContainsKey(c.getSessionID()))
            {
                tmp = cursorList[c.getSessionID()];
            }
            else
            {
                tmp = new ArrayList();
            }
            return tmp;
        }
    }
}